﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Diagnostics;
using System.ComponentModel;

/// <summary>
/// Summary description for EventLogs
/// </summary>
[DataObject(true)]
public class EventLogsWrapper
{
    public EventLogsWrapper()
    {
        System = (new EventLog("System")).Entries.Cast<EventLogEntry>().ToArray();
        Application = (new EventLog("Application")).Entries.Cast<EventLogEntry>().ToArray();
    }

    public EventLogEntry[] System { get; private set; }
    public EventLogEntry[] Application { get; private set; }

    public EventLogEntry[] GetEventLog(string eventLogName, int maximumRows, int startRowIndex)
    {
        var log = new EventLog(eventLogName);
        var query = from EventLogEntry entry in log.Entries
                    select entry;

        return query.Skip(startRowIndex).Take(maximumRows).ToArray();
    }
}
